package ch.zhaw.cctd.domain.map;

import java.awt.Dimension;
import java.awt.Point;
import java.io.Serializable;
import java.util.UUID;

import ch.zhaw.cctd.domain.GraphicalElement;
import ch.zhaw.cctd.domain.prototype.MapElementPrototype;

/**
 * Stellt ein quadratisches Element auf der Map dar. Ist verantwortlich für
 * Textur und Layer.
 * 
 * @author Rolf Koch
 */
public class MapElement extends Region implements GraphicalElement, Serializable {

	/**
	 * Serializable ID
	 */
	private static final long serialVersionUID = 1262923522078677116L;
	
	

	// Layer defines the layer in the Panel of the UI. Lower number means the
	// element gets overwritten by others with a higher Level
	private int layer;
	// Texture Filename
	private String texture;
	
	private UUID uid;

	/**
	 * default Constructor
	 * 
	 * @param point
	 * @param Dimension
	 * @param texturestring
	 * @param layerint
	 */
	public MapElement(Point point, Dimension d, String texture, int layer) {
		super(point, d);
		setTexture(texture);
		setLayer(layer);
		uid = UUID.randomUUID();
	}

	/**
	 * Prototype Constructor
	 * 
	 * @param MapElementPrototype
	 */
	public MapElement(MapElementPrototype w, String Texture) {
		this(new Point(w.getXX(), w.getXY()), new Dimension(w.getYX() - w.getXX(), w.getYY() - w.getXY()), Texture, w.getLayer());
	}

	/**
	 * Set the Texture as String
	 * 
	 * @param texture
	 */
	public void setTexture(String texture) {
		this.texture = texture;
	}

	/**
	 * Get the Texture as String
	 * 
	 * @return Texture String
	 */
	public String getTexture() {
		return texture;
	}

	/**
	 * Set Layer of this Map Element. Lower means Deeper
	 * 
	 * @param layer
	 */
	public void setLayer(int layer) {
		this.layer = layer;
	}

	/**
	 * Get Layer of this Map Element. Lower means Deeper
	 * 
	 * @return Layer ID INT
	 */
	public int getLayer() {
		return layer;
	}

	/**
	 * Returns a Unique ID of the Element
	 */
	@Override
	public UUID getUniqueId() {
		return this.uid;
	}

}
